package cn.iocoder.yudao.module.picturebook.dal.mysql.picturepost;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.picturebook.dal.dataobject.picturepost.PicturePostDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.picturebook.controller.admin.picturepost.vo.*;

/**
 * 帖子 Mapper
 *
 * @author 芋道源码
 */

@Mapper
public interface PicturePostMapper extends BaseMapperX<PicturePostDO> {

    default PageResult<PicturePostDO> selectPage(PicturePostPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PicturePostDO>()
                .eqIfPresent(PicturePostDO::getBookId, reqVO.getBookId())
                .eqIfPresent(PicturePostDO::getContext, reqVO.getContext())
                .eqIfPresent(PicturePostDO::getTitle, reqVO.getTitle())
                .eqIfPresent(PicturePostDO::getType, reqVO.getType())
                .eqIfPresent(PicturePostDO::getImageUrl, reqVO.getImageUrl())
                .betweenIfPresent(PicturePostDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PicturePostDO::getCreateTime)
        );
    }

}